package com.example.administrator.yunniuusedcar.adapter;

import android.content.Context;
import android.view.ViewGroup;
import com.example.administrator.common.ui.BaseAdapterRV;
import com.example.administrator.common.ui.BaseHolderRV;
import com.example.administrator.yunniuusedcar.holder.Info01NewBottomHolder;
import com.example.administrator.yunniuusedcar.holder.Info01NewHeaderHolder;
import com.example.administrator.yunniuusedcar.model.mode_benn.WZ_ArticlenListBean;
import com.example.administrator.yunniuusedcar.model.mode_benn.ZD_ArticleTopBean;

import java.util.List;

/**  咨讯 当日头条
 * Created by USER2015 on 2017/12/15.
 */

public class newsZiXunAdapter extends BaseAdapterRV {        //extends BaseAdapterRV

    public newsZiXunAdapter(Context context, List listData) {
        super(context, listData);
    }

    // viewType: 判断用来显示哪一种类型的item布局
    @Override
    public BaseHolderRV createViewHolder(Context context, ViewGroup parent, int viewType) {
        switch (viewType) {
            case ZX_TYPE_HEADER:
                return new Info01NewHeaderHolder(context, parent, this);      //置顶文章   MainNewInfoHolder

            case ZX_TYPE_SHOP:
                return new Info01NewBottomHolder(context, parent, this);    // Info01NewBottomHolder：文章列表   //Home02GridCarHolde

        }

        return null;
    }

    // 列表显示的三种类型
    private static final int ZX_TYPE_HEADER = 0;
    private static final int ZX_TYPE_SHOP = 1;

    // 判断列表项要显示的是哪一种类型
    @Override
    public int getItemViewType(int position) {
        Object bean = getItem(position);
//
        if (bean instanceof ZD_ArticleTopBean) {      // //置顶文章
            return ZX_TYPE_HEADER;
        }
//
        if (bean instanceof WZ_ArticlenListBean) {     // // 文章列表
            return ZX_TYPE_SHOP;
        }

        return -1;
    }
}
